#!/usr/bin/perl
# 2014/02/12 Count reads aligned to each chromosomes

use strict;
use warnings;
use IO::File;
use Getopt::Std;
use Carp qw(croak);
$| = 0;

if(@ARGV != 2 or $ARGV[0] eq '--help'){
	die "Usage : $0 -i [bam file]\n";
}

my %opt;
getopts("i:", \%opt);
my $FILE_bam = $opt{i};

foreach my $target(qw(I II III MT MTR AB325691)){
	my $count = `samtools view -c -F 4 $FILE_bam $target`;
	$count =~ s/\r?\n//;
	print "$target\t$count\n";
}
